package com.example.acceledemo;

import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;

public class WakeLockManager {
	
	WakeLock wLock;
	Context mContext;
	
	public WakeLockManager(Context context)
	{
		this.mContext=context;
		
		PowerManager pManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
		wLock = pManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "WakeLock");
	}
	
	public void acquire(String function) {

		wLock.acquire();
		Log.d("wake", function + "WakeLock acquire()::" + wLock.isHeld());

	}
	
	
	public void release(String function)
	{
		
		try
		{
			wLock.release();
			Log.d("wake", function + "::WakeLock release()::" + wLock.isHeld());
		}
		catch (Exception e)
		{
			Log.e("wake", "Exeption::" + function + " " + e.getMessage());
		}
				
	}
	



}
